package com.medord.machine.core.entity;

import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 孙丰佳
 * @version V1.0
 * @Title: FlowResult
 * @Package com.state.machine.entity
 * @Description: (用一句话描述该文件做什么)
 * @date 2021-07-14 16:46
 **/
public class FlowResult {
    private List<String> successList = new ArrayList<>();
    private List<String> warningList = new ArrayList<>();
    private List<String> errorList = new ArrayList<>();
    private Map data = new HashMap();

    public List<String> getSuccessList() {
        return successList;
    }

    public void setSuccessList(List<String> successList) {
        this.successList = successList;
    }

    public List<String> getWarningList() {
        return warningList;
    }

    public void setWarningList(List<String> warningList) {
        this.warningList = warningList;
    }

    public List<String> getErrorList() {
        return errorList;
    }

    public void setErrorList(List<String> errorList) {
        this.errorList = errorList;
    }

    public void addSuccessMsg(String msg) {
        this.successList.add(msg);
    }

    public void addError(String msg) {
        this.errorList.add(msg);
    }

    public void addWarning(String msg) {
        this.warningList.add(msg);
    }

    public void copyData(FlowResult result) {
        if (!ObjectUtils.isEmpty(result.getSuccessList())) {
            this.successList.addAll(result.getSuccessList());
        }
        if (!ObjectUtils.isEmpty(result.getErrorList())) {
            this.errorList.addAll(result.getErrorList());
        }
        if (!ObjectUtils.isEmpty(result.getWarningList())) {
            this.warningList.addAll(result.getWarningList());
        }
    }
}
